package com.mouse.magent.server.service;

import com.mouse.magent.common.net.TcpServer;
import com.mouse.magent.common.util.PropUtil;
import com.mouse.magent.server.constant.ServerConstant;
import com.mouse.magent.server.constant.ServiceCommand;
import com.mouse.magent.server.handler.ServerHandler;
import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;

@Slf4j
public class Proxy {
    public void start() throws Exception {
        Integer port = Integer.valueOf(PropUtil.getValue("server.port", "9999"));
        TcpServer tcpServer = new TcpServer();
        tcpServer.bind(port, new ServerHandler(), () -> Arrays.asList(ServiceCommand.values()));
        ServerConstant.setProxyChannelGroup(tcpServer.getChannelGroup());
        log.info("proxy load success,port:{}", port);

    }
}
